clicked = "";
function blankEntry(){
	if(clicked != 'true'){
		document.MyPopUp.source.selectedIndex = 0;
		document.MyPopUp.type.selectedIndex = 0;
		document.MyPopUp.title.value = "";
		clicked = 'true';
	}else{
		document.MyPopUp.source.selectedIndex = 4;
		document.MyPopUp.type.selectedIndex = 8;
		clicked = "";
	}
}




var xOffset = -165;
var yOffset = -250;
newX = "";
newY = "";
scrollAmount = 0;
function showPopup (targetObjectId,eventObj,hours,minutes,seconds,ampm,IDAnchor,statusID,porgramAnchor) {
	
	MyHours = hours;
if(MyHours != 'program'){//stuff for QuickAdd popup
	//Reset Form to Defaults
		document.MyPopUp.source.selectedIndex = 4;
		document.MyPopUp.type.selectedIndex = 7;
		document.MyPopUp.blank.checked = false;
		document.MyPopUp.title.value = "";
		document.MyPopUp.permanent.checked = false;
		document.MyPopUp.mon.checked = false;
		document.MyPopUp.tue.checked = false;
		document.MyPopUp.wed.checked = false;
		document.MyPopUp.thu.checked = false;
		document.MyPopUp.fri.checked = false;
		document.MyPopUp.sat.checked = false;
		document.MyPopUp.sun.checked = false;
		document.MyPopUp.Myanchor.value = IDAnchor;
		clicked = "";
		
		//check current days check box 
		eval("document.MyPopUp."+currentDay+".checked = true;");
		//document.MyPopUp.mon.checked = true;
		//alert(currentDay);
		
		
		document.MyPopUp.hour.selectedIndex = parseInt(hours);
		document.MyPopUp.minute.selectedIndex = parseInt(minutes) + 1; 
		if(seconds == '0'){
			document.MyPopUp.seconds.selectedIndex = 31;
		}else{
				document.MyPopUp.seconds.selectedIndex = 46;
		}
		if(ampm == 'am'){
			document.MyPopUp.ampm.selectedIndex = 0;
		}else{
			document.MyPopUp.ampm.selectedIndex = 1;
		}

}else{//stuff for Program Status Popup
	
	document.getElementById('confirm').innerHTML = "";

	confirmTitle = ampm;
	confirmTime = IDAnchor;
	//alert(IDAnchor);
	//document.getElementById('ProgramStatusDetails').innerHTML ="";
	
	//set all fields to default values
	document.ProgramStatusPopUp.reset();
	
	
	
	var formCheckBox = 'document.'+ seconds.name + '.' + minutes + '.checked';
	if(eval(formCheckBox) == false){
		document.ProgramStatusPopUp.active[1].checked = true;
	}else{
		document.ProgramStatusPopUp.active[0].checked = true;
	}
	
	
//set update ID of program
document.ProgramStatusPopUp.ID.value = statusID;

document.ProgramStatusPopUp.title.value = ampm;

document.ProgramStatusPopUp.time.value = IDAnchor;

document.ProgramStatusPopUp.myAnchor.value = porgramAnchor;


//reset Submit button to initla value
document.ProgramStatusPopUp.update.value= 'Verify Change';
armed = '';
	
}





if (self.innerWidth)//netscape flavors 
{
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
	scrollAmount = window.pageYOffset;
	//document.MyPopUp.title.focus()

}
else if (document.documentElement && document.documentElement.clientWidth)//IE 6
{
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
	scrollAmount = document.body.scrollTop;
}
else if (document.body)//All other flavors of IE
{
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
	scrollAmount = document.body.scrollTop;
}
//alert (scrollAmount);
if(newX == "" && MyHours != 'program'){
  newX = (frameWidth/2) - ((document.getElementById('spotInfo').offsetWidth)/2);
}else if(newX == "" && MyHours == 'program'){
  newX = (frameWidth/2) - ((document.getElementById('ProgramStatus').offsetWidth)/2);
}



if(newY == ""){
	 newY = ((frameHeight/2) - (document.getElementById(targetObjectId).offsetHeight/2)) + scrollAmount;
}else if(previousScroll == scrollAmount){
	 newY = document.getElementById(targetObjectId).offsetTop;
}else if(scrollAmount > previousScroll && ((scrollAmount - previousScroll) < distanceFromTop)){//scrolling down the oage
	newY = originaldistanceFromTop;
}else if(previousScroll > scrollAmount  && (((previousScroll - scrollAmount) + distanceFromTop) < (frameHeight - document.getElementById(targetObjectId).offsetHeight))){//scrollling upwards
	newY = originaldistanceFromTop;
}else{
  newY = distanceFromTop + scrollAmount;
}




	//document.getElementById("uw").innerHTML = UW;
	
    if(eventObj) {
	// hide any currently-visible popups
	hideCurrentPopup();
	// stop event from bubbling up any farther
	eventObj.cancelBubble = true;
	// move popup div to current cursor position 
	// (add scrollTop to account for scrolling for IE)

    //var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + ((document.body.scrollLeft)?document.body.scrollLeft:0);
	//var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
	
	

	
	
	moveObject(targetObjectId, newX, newY);
	// and make it visible
	if( changeObjectVisibility(targetObjectId, 'visible') ) {
	    // if we successfully showed the popup
	    // store its Id on a globally-accessible object
	    window.currentlyVisiblePopup = targetObjectId;
	    return true;

	} else {
	    // we couldn't show the popup, boo hoo!
	    return false;
	}
    } else {
	// there was no event object, so we won't be able to position anything, so give up
	return false;
    }


} // showPopup

function hideCurrentPopup() {
    // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
    if(window.currentlyVisiblePopup && MyHours == 'program') {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
	newX = document.getElementById('ProgramStatus').offsetLeft;
    }else if(window.currentlyVisiblePopup && MyHours != 'program') {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
	newX = document.getElementById('spotInfo').offsetLeft;
    }
	
  newY = distanceFromTop + scrollAmount;
} // hideCurrentPopup



// ***********************
// hacks and workarounds *
// ***********************

// initialize hacks whenever the page loads
//window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
document.onclick = hideCurrentPopup;

function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix() {
    location.reload(false);
}

